package com.xinfan.io.homework;

import java.io.*;
import java.util.Properties;

/**
 * @Author xin
 * @Date 2022/6/9 14:48
 * @Version 1.0
 */
public class Homework3 {
    public static void main(String[] args) throws IOException {

        Properties properties = new Properties();
        String src = "src\\dog.properties";
        properties.load(new BufferedReader(new FileReader(src)));

        Dog dog = new Dog(properties.getProperty("name"),
                Integer.parseInt(properties.getProperty("age")),
                properties.getProperty("color"));


        System.out.println(dog);

        String des = "G:\\桌面\\dog.dat";

        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(des));
        oos.writeObject(dog);

        //关闭流 ！！！！！！！
        oos.close();




    }
}

class Dog implements Serializable {
    private static final long serialVersionUID = 4860959926556110743L;
    private String name;
    private int age;
    private String color;

    public Dog(String name, int age, String color) {
        this.name = name;
        this.age = age;
        this.color = color;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", color='" + color + '\'' +
                '}';
    }
}
